angular.module('app').directive('fileModel', $parse => ({
    restrict: 'A',
    link(scope, element, attrs) {
        var model = $parse(attrs.fileModel);
        var modelSetter = model.assign;
        element.on('change', () => {
            scope.$apply(() => {
                modelSetter(scope, element[0].files[0]);
            });
        });
    }
}));